home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / bbs / cit_src_7H21.lha / slist.h < prev    next >
C/C++ Source or Header  |  1997-08-14  |  4KB  |  91 lines

  1. /************************************************************************/
  2. /*                             sList.h                                  */
  3. /*      #include file for List.C.                                       */
  4. /************************************************************************/
  5. /************************************************************************/
  6. /*              List handling structures - generic sorted lists         */
  7. /************************************************************************/
  8. #ifndef slist_h
  9. #define slist_h
  10. typedef struct Slist      SListData;
  11. typedef struct sbasestuff SListBase;
  12. typedef void (*INTERATOR)();
  13. #define GetFirst(x)     (((x)->start != NULL) ? (x)->start->data :(void *)NULL)
  14. #define MoveAndClear(s, d)      (d)->start = (s)->start, (s)->start = NULL
  15. /*
  16. * This is the generic list structure normal link.  It contains a pointer
  17. * to the next element in the list and a pointer to a chunk of data.
  18. */
  19. struct Slist
  20.   {
  21.   void     *data;
  22.   SListData *next;
  23.  
  24.   };
  25. /*
  26. * This structure contains data and functions necessary to handle some given
  27. * instantiation of a list.  Included is a pointer to the data of the list,
  28. * and pointers to functions which should always be used for given functions
  29. * applied to the list.
  30. */
  31. struct sbasestuff
  32.   {
  33.   SListData *start;
  34.   void     *(*CheckIt) (void *d1, void *d2);
  35.   int       (*cmp)     (void *d1, void *d2);
  36.   void      (*FreeFunc)(void *d);
  37.   void     *(*EatLine) (char *line);
  38.  
  39.   };
  40. #define InitListValues(l, ci, xcmp, f, e)       (l)->start = NULL, (l)->CheckIt = ci,   (l)->cmp = xcmp, (l)->FreeFunc = f, (l)->EatLine = e
  41. /*
  42. * These definitions are for the listshow functions: behavior specification.
  43. */
  44. #define NO_REFRESH      0x01    /* for use with the mode argument       */
  45. #define ADVANCE         0x02    /* advance one in list                  */
  46. #define DEL_ACTIVE      0x04    /* if DEL is active                     */
  47. #define NO_HEADER       0x08    /* No header on list if set             */
  48. #define NO_ACTION       0x10    /* do nothing - just display            */
  49. #define PAGE_LABELS     0x20    /* show page labels                     */
  50. #define NO_BAR          0x40    /* show page labels                     */
  51. /*
  52. * These definitions are mode definitions of ListShow.
  53. */
  54. #define LS_NORMAL       0
  55. #define LS_ONTOP        1
  56. /*
  57. * This structure is used by listshow.c for displaying lists of data in
  58. * dynamic columns.
  59. */
  60. typedef struct
  61.   {
  62.   SListBase Data;
  63.   char *title;
  64.   int *critical;                  /* chars which cause exit       */
  65.   char (*DelFunc)();              /* If DEL key is touched        */
  66.   int left, right, top, bottom;   /* window to display in         */
  67.   int fg, bg, dfg, dbg;           /* colors                       */
  68.   int ColWidth;                   /* how wide are columns?        */
  69.   void (*DispFunc)();             /* displays data for you        */
  70.   char (*SelectorId)();         /* see if the selector agrees   */
  71.   int  (*UserInput)();
  72.  
  73.   }
  74. DisplayList;
  75. void *DispList     (DisplayList *, void *, int  *, int);
  76. char  MakeList     (SListBase *, char *, FILE *);
  77. void  AddData      (SListBase *, void *, void (*)(void *), int );
  78. void  KillData     (SListBase *, void *);
  79. void AltKillData   (SListBase *base, void *(*check)(), void *data);
  80. void KillList      (SListBase *);
  81. void *GetLast      (SListBase *);
  82. void *SearchList   (SListBase *, void *);
  83. void *AltSearchList(SListBase *base, void *(*doit)(), void *data);
  84. int  RunList       (SListBase *, void (*)(void *));
  85. int  RunListA      (SListBase *base, void (*doit)(void *data, void *rg), void *arg);
  86. void FrontToEnd    (SListBase *);
  87. void NoFree        (void *);
  88. char *GetAString   (char *, int , FILE *);
  89. void MaybeKillList (SListBase *base, int (*func)());
  90. #endif
  91.